加油~這是 python 數一數二最常使用到的工具了
一定要好好學習喔~~
counter = {}
for word in input().split():
counter[word] = counter.get(word, 0) + 1
print(counter[word] - 1, end=' ')
n = int(input())
d = {}
for i in range(n):
first, second = input().split()
d[first] = second
d[second] = first
print(d[input()])
num_votes = {}
for _ in range(int(input())):
candidate, votes = input().split()
num_votes[candidate] = num_votes.get(candidate, 0) + int(votes)
for candidate, votes in sorted(num_votes.items()):
print(candidate, votes)
counter = {}
for i in range(int(input())):
line = input().split()
for word in line:
counter[word] = counter.get(word, 0) + 1
max_count = max(counter.values())
most_frequent = [k for k, v in counter.items() if v == max_count]
print(min(most_frequent))
OPERATION_PERMISSION = {
'read': 'R',
'write': 'W',
'execute': 'X',
}
file_permissions = {}
for i in range(int(input())):
file, *permissions = input().split()
file_permissions[file] = set(permissions)
for i in range(int(input())):
operation, file = input().split()
if OPERATION_PERMISSION[operation] in file_permissions[file]:
print('OK')
else:
print('Access denied')
motherland = {}
for i in range(int(input())):
country, *cities = input().split()
for city in cities:
motherland[city] = country
for i in range(int(input())):
print(motherland[input()])
from collections import Counter
words = []
for _ in range(int(input())):
words.extend(input().split())
counter = Counter(words)
pairs = [(-pair[1], pair[0]) for pair in counter.most_common()]
words = [pair[1] for pair in sorted(pairs)]
print('\n'.join(words))
from collections import defaultdict
latin_to_english = defaultdict(list)
for i in range(int(input())):
english_word, latin_translations_chunk = input().split(' - ')
latin_translations = latin_translations_chunk.split(', ')
for latin_word in latin_translations:
latin_to_english[latin_word].append(english_word)
print(len(latin_to_english))
for latin_word, english_translations in sorted(latin_to_english.items()):
print(latin_word + ' - ' + ', '.join(english_translations))